import { PathFinderManager } from "../PathFinderManager";
import { ACostDecorate } from "./ACostDecorate";

/**
 * 普通建筑设置,会排除掉星门
 */
export class ACreepSetCreepBlock extends ACostDecorate
{
    decorate(manager:PathFinderManager,roomName: string, costs: CostMatrix,opt:IPathFinderOpt): CostMatrix
    {
        if(!manager._blockCreeps[roomName])
        {
            return costs
        }
        const creepnames = Object.keys(manager._blockCreeps[roomName]);
        for(let idx=0;idx<creepnames.length; idx++)
        {
            const creep = Game.creeps[creepnames[idx]];
            if(creep)
            {
                if(creep.pos.roomName == roomName)
                {
                    costs.set(creep.pos.x, creep.pos.y, 0xff);
                }


            }
            else
            {
                delete manager._blockCreeps[creepnames[idx]];

            }
        }
        return  costs
    }

}
